//package com.rp.news.swagger;
//
//import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
//import com.google.common.collect.Lists;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Import;
//import org.springframework.context.annotation.Profile;
//import org.springframework.web.bind.annotation.RestController;
//import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
//import springfox.documentation.builders.ApiInfoBuilder;
//import springfox.documentation.builders.ParameterBuilder;
//import springfox.documentation.builders.PathSelectors;
//import springfox.documentation.builders.RequestHandlerSelectors;
//import springfox.documentation.schema.ModelRef;
//import springfox.documentation.service.*;
//import springfox.documentation.spi.DocumentationType;
//import springfox.documentation.spi.service.contexts.SecurityContext;
//import springfox.documentation.spring.web.plugins.Docket;
//import springfox.documentation.swagger2.annotations.EnableSwagger2;
//
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * swagger 文档
// *
// * @author 笛安
// */
//@Configuration
//@EnableSwagger2
//@Profile({"!prod"})
//@EnableKnife4j
//@Import(BeanValidatorPluginsConfiguration.class)
//public class SwaggerConfiguration {
//
//  @Bean
//  public Docket groupRestApi() {
//    //    // 头部参数
//    String parameterType = "header";
//    ModelRef modelRef = new ModelRef("string");
//    List<Parameter> headers = new ArrayList<>();
//
////    headers.add(
////        new ParameterBuilder()
////            .name(UserUtils.AUTH_KEY_SELLER_NO)
////            .description("商户ID")
////            .modelRef(modelRef)
////            .parameterType(parameterType)
////            .required(false)
////            .defaultValue("****")
////            .build());
////    headers.add(
////        new ParameterBuilder()
////            .name(UserUtils.AUTH_KEY_USER_ID)
////            .description("用户ID")
////            .modelRef(modelRef)
////            .parameterType(parameterType)
////            .required(false)
////            .defaultValue("*****")
////            .build());
////    headers.add(
////        new ParameterBuilder()
////            .name(UserUtils.AUTH_KEY_USER_ROLE)
////            .description("用户角色")
////            .modelRef(modelRef)
////            .parameterType(parameterType)
////            .required(false)
////            .defaultValue("2")
////            .build());
////    headers.add(
////        new ParameterBuilder()
////            .name(UserUtils.AUTH_KEY_USER_ENTITY_NO)
////            .description("用户主体编号")
////            .modelRef(modelRef)
////            .parameterType(parameterType)
////            .required(false)
////            .defaultValue("********")
////            .build());
////    headers.add(
////        new ParameterBuilder()
////            .name(UserUtils.AUTH_HEADER_NAME)
////            .description("token")
////            .modelRef(modelRef)
////            .parameterType(parameterType)
////            .required(false)
////            .defaultValue(
////                "********")
////            .build());
//
//    return new Docket(DocumentationType.SWAGGER_2)
//        .apiInfo(groupApiInfo())
//        .select()
//        .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
//        .paths(PathSelectors.any())
//        .build()
//        .securityContexts(Lists.newArrayList(securityContext(), securityContext1()))
//        .securitySchemes(Lists.<SecurityScheme>newArrayList(apiKey(), apiKey1()))
//        .globalOperationParameters(headers);
//  }
//
//  private ApiInfo groupApiInfo() {
//    return new ApiInfoBuilder()
//        .title("swagger文档")
//        .description(
//            "<div style='font-size:14px;color:red;'>swagger-bootstrap-ui-demo RESTful APIs</div>")
//        .termsOfServiceUrl("*****")
//        .contact("****")
//        .version("2.0")
//        .build();
//  }
//
//  private ApiKey apiKey() {
//    return new ApiKey("BearerToken", "Authorization", "header");
//  }
//
//  private ApiKey apiKey1() {
//    return new ApiKey("BearerToken1", "Authorization-x", "header");
//  }
//
//  private SecurityContext securityContext() {
//    return SecurityContext.builder()
//        .securityReferences(defaultAuth())
//        .forPaths(PathSelectors.regex("/.*"))
//        .build();
//  }
//
//  private SecurityContext securityContext1() {
//    return SecurityContext.builder()
//        .securityReferences(defaultAuth1())
//        .forPaths(PathSelectors.regex("/.*"))
//        .build();
//  }
//
//  List<SecurityReference> defaultAuth() {
//    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
//    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
//    authorizationScopes[0] = authorizationScope;
//    return Lists.newArrayList(new SecurityReference("BearerToken", authorizationScopes));
//  }
//
//  List<SecurityReference> defaultAuth1() {
//    AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
//    AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
//    authorizationScopes[0] = authorizationScope;
//    return Lists.newArrayList(new SecurityReference("BearerToken1", authorizationScopes));
//  }
//}